﻿@using Coralcode.Base.Utils
@using CoralNode.Core.Entity.Domains.Prototype
@using CoralNode.Core.Entity.Enums
@using CoralNode.MvcClient.Helper
<!--left-->
@Html.IncludePage("CoralAdmin/Search", "_Left",new {url="SetFieldIndexAction"})
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_system"></span><span class="t t_c">索引管理</span>
        </div>
        <div id="main">
            <div class="line_solid clearfix">
                <div class="select_owner w_11 mr_1" data-meta="{value:'@ViewBag.PrototypeId',name:'PrototypeId', btn:'<span class=\'ico ico_slide_down\'></span>' , clickbtn:'<span class=\'ico ico_slide_up\'></span>'}">
                    <ul>
                        @foreach (var item in @ViewBag.PrototypeList) {
                            <li data-value="@item.Id"><a href="/m/search/setfieldindexaction?PrototypeId=@item.Id">@item.Title</a></li>
                        }
                    </ul>
                </div>
                <div class="ml_12">
                    <div class="">
                        @using (Html.BeginForm("SetFieldIndexAction", "Search", FormMethod.Post))
                        {
                            <div class="tablelist_style1" data-js="tabellist_style1">
                                <table cellpadding="0" cellspacing="0" class="mt_3-5">
                                    <tr class="exclude">
                                        <th width="100" align="center">ID</th>
                                        <th width="300" align="left">字段名</th>
                                        <th width="100" align="center">字段类型</th>
                                        <th>索引设置</th>
                                    </tr>
                                    @foreach (PrototypeFieldDomain item in ViewBag.Fields)
                                    {
                                        <tr>
                                            <td>@item.Id</td>
                                            <td class="td_left">@item.Title</td>
                                            @{
                                                var filedType = EnumUtil.GetEnumDescription(NodeEnums.BasicFieldType, @item.FieldType);
                                                if (string.IsNullOrEmpty(filedType)) {
                                                    filedType = EnumUtil.GetEnumDescription(NodeEnums.FunctionFieldType, item.FieldType);
                                                }
                                            }
                                            <td width="td_left">@filedType</td>
                                            <td>
                                                <select name="field_@item.Id" @if(ViewBag.FieldsIndexAction[item.Id].CannotChange){@String.Format("disabled=disabled")}>
                                                    @foreach (var keyvalue in ViewBag.IndexActionList)
                                                    {
                                                        <option value="@keyvalue.Value" @if (ViewBag.FieldsIndexAction[item.Id].IndexActionDomain.IndexAction == keyvalue.Value)
                                                                                        {
                                                                                            @String.Format("selected=selected")
                                                                                        } >@keyvalue.Key</option>
                                                    }
                                                </select>
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            @Html.Hidden("prototypeId",(long)ViewBag.PrototypeId)
                            <div class="global_fun p_2">
                                <input type="submit" class="btn_1" value="提交" />
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>